g_signal_emit (frame_clock, signals[FLUSH_EVENTS], 0);
if (GDK_PROFILER_IS_RUNNING)
- {
- gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "frameclock", "flush-events");
- }
+ gdk_profiler_end_mark (before, "frameclock", "flush-events");
}
void
g_signal_emit (frame_clock, signals[BEFORE_PAINT], 0);
if (GDK_PROFILER_IS_RUNNING)
- {
- gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "frameclock", "before-paint");
- }
+ gdk_profiler_end_mark (before, "frameclock", "before-paint");
}
void
g_signal_emit (frame_clock, signals[UPDATE], 0);
if (GDK_PROFILER_IS_RUNNING)
- {
- gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "frameclock", "update");
- }
+ gdk_profiler_end_mark (before, "frameclock", "update");
}
void
g_signal_emit (frame_clock, signals[LAYOUT], 0);
if (GDK_PROFILER_IS_RUNNING)
- {
- gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "frameclock", "layout");
- }
+ gdk_profiler_end_mark (before, "frameclock", "layout");
}
void
g_signal_emit (frame_clock, signals[PAINT], 0);
if (GDK_PROFILER_IS_RUNNING)
- {
- gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "frameclock", "paint");
- }
+ gdk_profiler_end_mark (before, "frameclock", "paint");
}
void
g_signal_emit (frame_clock, signals[AFTER_PAINT], 0);
if (GDK_PROFILER_IS_RUNNING)
- {
- gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "frameclock", "after-paint");
- }
+ gdk_profiler_end_mark (before, "frameclock", "after-paint");
}
void
g_signal_emit (frame_clock, signals[RESUME_EVENTS], 0);
if (GDK_PROFILER_IS_RUNNING)
- {
- gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "frameclock", "resume-events");
- }
+ gdk_profiler_end_mark (before, "frameclock", "resume-events");
}
static gint64
priv->sleep_serial = get_sleep_serial ();
if (GDK_PROFILER_IS_RUNNING)
- gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "frameclock", "paint_idle");
+ gdk_profiler_end_mark (before, "frameclock", "paint_idle");
return FALSE;
}
{
if (priv->freeze_time != 0)
{
- gint64 thaw_time = g_get_monotonic_time ();
- gdk_profiler_add_mark (priv->freeze_time,
- (thaw_time - priv->freeze_time),
- "frameclock freeze", "");
+ gdk_profiler_end_mark (priv->freeze_time,
+ "frameclock freeze", NULL);
priv->freeze_time = 0;
}
}
"gtk", name, message);
}
+static void
+add_markvf (gint64 start,
+ guint64 duration,
+ const char *name,
+ const char *format,
+ va_list args)
+{
+ char *message;
+ message = g_strdup_vprintf (format, args);
+ sysprof_capture_writer_add_mark (writer,
+ start * 1000L,
+ -1, getpid (),
+ duration * 1000L,
+ "gtk", name, message);
+ g_free (message);
+}
+
void
gdk_profiler_add_markf (gint64 start,
guint64 duration,
...)
{
va_list args;
- char *message;
if (!running)
return;
va_start (args, format);
- message = g_strdup_vprintf (format, args);
+ add_markvf (start, duration, name, format, args);
va_end (args);
+}
+
+void
+gdk_profiler_end_mark (gint64 start,
+ const char *name,
+ const char *message)
+{
+ if (!running)
+ return;
sysprof_capture_writer_add_mark (writer,
start * 1000L,
-1, getpid (),
- duration * 1000L,
+ (g_get_monotonic_time () - start) * 1000L,
"gtk", name, message);
- g_free (message);
}
+void
+gdk_profiler_end_markf (gint64 start,
+ const char *name,
+ const char *format,
+ ...)
+{
+ va_list args;
+
+ if (!running)
+ return;
+
+ va_start (args, format);
+ add_markvf (start, g_get_monotonic_time () - start, name, format, args);
+ va_end (args);
+}
+
+
static guint
define_counter (const char *name,
const char *description,
{
}
+void
+gdk_profiler_end_mark (gint64 start,
+ const char *name,
+ const char *message)
+{
+}
+
+void
+gdk_profiler_end_markf (gint64 start,
+ const char *name,
+ const char *format,
+ ...)
+{
+}
+
guint
gdk_profiler_define_counter (const char *name,
const char *description)
const char *name,
const char *format,
...) G_GNUC_PRINTF (4, 5);
+void gdk_profiler_end_mark (gint64 start,
+ const char *name,
+ const char *message);
+void gdk_profiler_end_markf (gint64 start,
+ const char *name,
+ const char *format,
+ ...) G_GNUC_PRINTF (3, 4);
guint gdk_profiler_define_counter (const char *name,
const char *description);
void gdk_profiler_set_counter (guint id,
g_value_unset (&v);
if (GDK_PROFILER_IS_RUNNING)
- {
- gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "wayland", "load cursor theme");
- }
+ gdk_profiler_end_mark (before, "wayland", "load cursor theme");
}
gsk_gl_shadow_cache_init (&self->shadow_cache);
if (GDK_PROFILER_IS_RUNNING)
- gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "gl renderer realize", NULL);
+ gdk_profiler_end_mark (before, "gl renderer realize", NULL);
return TRUE;
}
before2 = g_get_monotonic_time ();
gtk_init ();
if (GDK_PROFILER_IS_RUNNING)
- gdk_profiler_add_mark (before2, (g_get_monotonic_time () - before2), "gtk init", NULL);
+ gdk_profiler_end_mark (before2, "gtk init", NULL);
priv->impl = gtk_application_impl_new (application, gdk_display_get_default ());
gtk_application_impl_startup (priv->impl, priv->register_session);
gtk_application_load_resources (application);
if (GDK_PROFILER_IS_RUNNING)
- gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "gtk application startup", NULL);
+ gdk_profiler_end_mark (before, "gtk application startup", NULL);
}
static void
/* restore the original domain */
gtk_builder_set_translation_domain (builder, domain);
- gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "builder load", filename);
+ gdk_profiler_end_mark (before, "builder load", filename);
}
#endif
if (GDK_PROFILER_IS_RUNNING)
- gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "create selector tree", NULL);
+ gdk_profiler_end_mark (before, "create selector tree", NULL);
}
static void
if (GDK_PROFILER_IS_RUNNING)
{
char *uri = g_file_get_uri (file);
- gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "theme load", uri);
+ gdk_profiler_end_mark (before, "theme load", uri);
g_free (uri);
}
}
chooser->populate_idle = 0;
if (GDK_PROFILER_IS_RUNNING)
- {
- now = g_get_monotonic_time ();
- gdk_profiler_add_mark (start, (now - start), "emojichooser", "populate (finish)");
- }
+ gdk_profiler_end_mark (start, "emojichooser", "populate (finish)");
return G_SOURCE_REMOVE;
}
load_themes (self);
if (GDK_PROFILER_IS_RUNNING)
- gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "icon theme load", self->current_theme);
+ gdk_profiler_end_mark (before, "icon theme load", self->current_theme);
if (was_valid)
queue_theme_changed (self);
g_assert (icon->texture != NULL);
if (GDK_PROFILER_IS_RUNNING)
- gdk_profiler_add_markf (before, g_get_monotonic_time () - before, in_thread ? "icon load (thread)" : "icon load" ,
+ gdk_profiler_end_markf (before, in_thread ? "icon load (thread)" : "icon load" ,
"%s size %d@%d", icon->filename, icon->desired_size, icon->desired_scale);
}
GskRenderer *renderer;
GskRenderNode *root;
int x, y;
- gint64 before = g_get_monotonic_time ();
- gint64 after = 0;
+ gint64 before_snapshot = g_get_monotonic_time ();
+ gint64 before_render = 0;
if (!GTK_IS_NATIVE (widget))
return;
if (GDK_PROFILER_IS_RUNNING)
{
- after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "widget snapshot", "");
+ before_render = g_get_monotonic_time ();
+ gdk_profiler_add_mark (before_snapshot, (before_render - before_snapshot), "widget snapshot", "");
}
if (root != NULL)
gsk_render_node_unref (root);
if (GDK_PROFILER_IS_RUNNING)
- {
- before = after;
- after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "widget render", "");
- }
+ gdk_profiler_end_mark (before_render, "widget render", "");
}
}
gtk_window_move_resize (self);
if (GDK_PROFILER_IS_RUNNING)
- {
- gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before, (after - before), "size allocation", "");
- }
+ gdk_profiler_end_mark (before, "size allocation", "");
}
static void